import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login.vue'
import Index from '../views/index.vue'
import qualification from '../views/qualification.vue'
import qualificationEdit from '../views/qualificationEdit.vue'
import aptitude from '../views/aptitude.vue'
import aptitudeEdit from '../views/aptitudeEdit.vue'
import aptitudeDetails from '../views/aptitudeDetails.vue'
import aptitudeAdd from '../views/aptitudeAdd.vue'
import report from '../views/report.vue'
import copyright from '../views/copyright.vue'
import help from '../views/help.vue'
import helpEdit from '../views/helpEdit.vue'
import advertising from '../views/advertising.vue'
import classification from '../views/classification.vue'
import coupon from '../views/coupon.vue'
import marketingPopularize from '../views/marketingPopularize.vue'
import marketingPopularizeView from '../views/marketingPopularizeView.vue'
import marketingPopularizeEdit from '../views/marketingPopularizeEdit.vue'
import uerManagement from '../views/uerManagement.vue'
import operatorLog from '../views/operatorLog.vue'
import serviceIndex from '../views/serviceIndex.vue'
import financeBusinessesAccount from '../views/financeBusinessesAccount.vue'
import financeBusinessesTrade from '../views/financeBusinessesTrade.vue'
import financeBusinessesRefund from '../views/financeBusinessesRefund.vue'
import financeBusinessesSettlement from '../views/financeBusinessesSettlement.vue'
import employee from '../views/employee.vue'
import employeeRole from '../views/employeeRole.vue'
import businessCorrelation from '../views/businessCorrelation.vue'
import businessLabel from '../views/businessLabel.vue'


// 修改页面路由重复点击报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)
 
// 修改页面路由重复点击报错
// const originalPush = router.prototype.push
// router.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }

const routes = [
  {
    path: '/',
    name: 'login',
    component:Login
  },
  {
    path: '/index',
    component:Index,
    children:[
      //财务管理
      {
        path: 'financeBusinessesAccount',
        component:financeBusinessesAccount,
      },
      //财务-交易明细
      {
        path: 'financeBusinessesTrade',
        component:financeBusinessesTrade,
      },
      //财务-退款订单查询
      {
        path: 'financeBusinessesRefund',
        component:financeBusinessesRefund,
      },
      //财务-商户结算设置
      {
        path: 'financeBusinessesSettlement',
        component:financeBusinessesSettlement,
      },
      //用户管理
      {
        path: 'uerManagement',
        component:uerManagement,
      },
      {
        path: 'operatorLog',
        component:operatorLog,
      },
      //资质
      {
        path: 'qualificationEdit',
        component:qualificationEdit,
      },
      //资质编辑
      {
        path: '/',
        component:qualification,
      },
      //规则/协议
      {
        path: 'aptitude',
        component:aptitude,
      },
      //协议编辑
      {
        path: 'aptitudeEdit',
        component:aptitudeEdit,
      },
      //协议详情
      {
        path: 'aptitudeDetails',
        component:aptitudeDetails,
      },
      //添加协议
      {
        path: 'aptitudeAdd',
        component:aptitudeAdd,
      },
       //举报信息
       {
        path: 'report',
        component:report,
      },
      //版权信息
      {
        path: 'copyright',
        component:copyright,
      },
      //优惠券
      {
        path: 'coupon',
        component:coupon,
      },
      //新人推广
      {
        path: 'marketingPopularize',
        component:marketingPopularize,
      },
      //新人推广-创建
      {
        path: 'marketingPopularizeEdit',
        component:marketingPopularizeEdit,
      },
      //新人推广-查看
      {
        path: 'marketingPopularizeView',
        component:marketingPopularizeView,
      },
      //员工管理
      {
        path: 'employee',
        component:employee,
      },
      //员工管理-角色管理
      {
        path: 'employeeRole',
        component:employeeRole,
      },
      //商家相关-标签管理
      {
        path: 'businessCorrelation',
        component:businessCorrelation,
      },
      //商家相关-商家跟进标签
      {
        path: 'businessLabel',
        component:businessLabel,
      },
      //帮助中心
      {
        path: 'help',
        component:help,
      },
      //帮助中心发布
      {
        path: 'helpEdit',
        component:helpEdit,
      },
      //广告管理
      {
        path: 'advertising',
        component:advertising,
      },
      {
        path: 'serviceIndex',
        component:serviceIndex,
      },
       //分类管理
      //  {
      //   path: 'classification',
      //   component:classification,
      //   // meta:{
      //   //     requireAuth:true
      //   //  }
      // },
    ],
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
    meta:{
        requireAuth:true
    }
  }
]

const router = new VueRouter({
  routes,
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  },
})

export default router
